#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<int> A, C;
int B, r;

vector<int> div(vector<int> &A, int &B, int &r)
{
    vector<int> C;
    r = 0;
    for (int i = A.size() - 1; i >= 0; --i)
    {
        r = r * 10 + A[i];
        C.push_back(r / B);
        r %= B;
    }
    reverse(C.begin(), C.end());
    while (C.size() > 1 && C.back() == 0)
        C.pop_back();
    return C;
}

int main()
{
    ios::sync_with_stdio(false);
    string a;
    cin >> a >> B;
    for (int i = a.size() - 1; i >= 0; --i)
        A.push_back(a[i] - '0');
    C = div(A, B, r);
    for (int i = C.size() - 1; i >= 0; --i)
        printf("%d", C[i]);
    printf("\n%d", r);
    return 0;
}